#基础镜像
FROM node:16-alpine as builder

ARG env=""
ENV env ${env}
RUN echo ${env}

ADD package.json /tmp/package.json
RUN cd /tmp && npm config set registry https://registry.npm.taobao.org && npm install

RUN mkdir /application/ && cp -a /tmp/node_modules /application/
WORKDIR /application/

ADD . /application/
RUN npm run build:${env}

#多阶段构建
FROM nginx:alpine
COPY ./default.conf /etc/nginx/conf.d/
COPY --from=builder /application/dist/ /usr/share/nginx/html/
